package com.qidianit.mes.pro.service.impl;

import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.qidianit.mes.pojo.Result;
import com.qidianit.mes.pojo.pro.Workflow;
import com.qidianit.mes.pro.mapper.WorkflowMapper;

import com.qidianit.mes.pro.service.WorkflowService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * @Description:
 * @Author: wang fei long
 * @Date: 2025/9/17 0017 - 16:10
 */
@Service
public class WorkflowServiceImpl implements WorkflowService {

    @Autowired
    private WorkflowMapper workflowMapper ;

    @Override
    public Result<PageInfo<Workflow>> selectList(Workflow workflow, int pageNum, int pageSize) {
        PageHelper.startPage(pageNum,pageSize);
        List<Workflow> workflows=workflowMapper.selectlist(workflow);
        return Result.success(new PageInfo<>(workflows));
    }

    @Override
    public Result<Workflow> selectByCode(String workflowCode) {
        return Result.success(workflowMapper.selectByCode(workflowCode));

    }

    @Override
    public Result<Workflow> saveWorkflow(Workflow workflow) {
        return workflowMapper.saveWorkflow(workflow)==1?Result.success():Result.error("操作失败");
    }

    @Override
    public Result<Workflow> updateWorkflow(Workflow workflow) {
        return workflowMapper.updateWorkflow(workflow)==1?Result.success():Result.error("操作失败");
    }

    @Override
    public Result deleteById(Long id) {
        return workflowMapper.deleteById(id)==1?Result.success():Result.error("操作失败");
    }

    @Override
    public Result batchDelete(Long[] ids) {
        return workflowMapper.batchDelete(ids)>0?Result.success():Result.error("操作失败");
    }


}
